//
//  SettingButton.m
//  WeiXin
//
//  Created by wwj on 15/12/8.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "SettingButton.h"
#define kMargin 7

@implementation SettingButton

-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    CGFloat y = kMargin;
    CGFloat wh = contentRect.size.height - y*2;
    CGFloat x = contentRect.size.width - wh;
    if ([self titleForState:UIControlStateNormal]) {
        x = 0;
    }
    return CGRectMake(x, y, wh, wh);
}

-(CGRect)titleRectForContentRect:(CGRect)contentRect{
    
    if (_right) {
        return contentRect;
    }
    CGFloat x = 10;
    if ([self imageForState:UIControlStateNormal]) {
        x = contentRect.size.height - kMargin*2 +10;
    }
    
    CGFloat w = contentRect.size.width;
    CGFloat h = contentRect.size.height;
    CGFloat y = 0;
    return CGRectMake(x, y, w, h);
}

@end
